package com.neuedu.servlet;

import com.neuedu.entity.Admin;
import com.neuedu.service.AdminService;
import com.neuedu.service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @标 题： 龙猫电商管理平台
 * @项目名称： YD-WebShop
 * @作 者： 侯建军
 * @日 期： 2019/6/19  14:00
 */
//@WebServlet(name = "LoginServlet",urlPatterns = {"/login"})
@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String adminName=request.getParameter("adminName");
        String password=request.getParameter("password");
        AdminService adminService=new AdminServiceImpl();
        Admin admin=adminService.login(adminName,password);
        if(null!=admin){
            response.sendRedirect("/index.jsp");
        }else{
            response.sendRedirect("/fail.jsp");
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.print("接收到请求");
    }
}
